package com.bjdd.jdy.ui.orderDetail;

import android.location.Location;

import com.baidu.location.BDLocation;
import com.baidu.mapapi.model.LatLng;
import com.baidu.mapapi.utils.DistanceUtil;
import com.bjdd.jdy.Constant;
import com.bjdd.jdy.baidu.LocationUtils;
import com.bjdd.jdy.util.JumpUtil;
import com.bjdd.jdy.util.L;
import com.bjdd.jdy.util.SpUtil;
import com.bjdd.jdy.util.T;

/**
 * Created by Administrator on 2017/5/3.
 */

public class OrderDetailPresenter extends OrderDetailContract.Presenter {
    private double lat,lng;
    @Override
    public void onStart() {
        rxManager.on(Constant.SHOW_LOADING, msg -> showLoadingDialog((Boolean) msg));
        rxManager.on(Constant.HIDE_LOADING,msg -> hideLoadingDialog());
        if (SpUtil.getUser() == null || SpUtil.getUser().equals("") || SpUtil.getUser().getCarrierId() == null) {
            JumpUtil.toLogin(context);
            return;
        }
    }

    @Override
    void getOrderInfo(String orderNo) {
        showLoadingDialog(false);
        String token = SpUtil.getToken();
        rxManager.add(model.getOrderInfo(token,orderNo)
        .subscribe(result -> {
            hideLoadingDialog();
            if (!result.isError()){
                view.infoBack(result.getData());
            }else {
                T.show(result.getMsg());
            }
        },e -> {
            hideLoadingDialog();
            T.show("获取订单失败");
        }));
    }


}
